requireJS(['constant', 'site', 'handlebars'], function (Constant, site, Handlebars) {
    var url = {
        selectRights:"manager/selectRights.do"
    }

    var products = {}
    var firstList;

    site.send({
        url:url.selectRights,
        callback:function(data){
            data = JSON.parse(data);
            if(data.type == '1'){
                var list = data.content;
                firstList = data;
                var source = $("#mylimsList_content_tpl").html();
                var template = Handlebars.compile(source);
                var html = template(data);
                $("#mylimsList_content").html(html)

                var source = $("#column_list_tpl").html();
                var template = Handlebars.compile(source);
                var html = template(data);
                $("#column_list").append(html)

                for (var i = 0; i < list.length; i++) {
                    var v = list[i];
                    products[v.id] = v;
                }
            }
            else{
                Constant.fn.Message("F",data.msg);
            }
        }
    })


    $('.sousuo').on('click',function(){
        var id = $("#column_list").val();
        if(id){
            var source = $("#single_content_tpl").html();
            var template = Handlebars.compile(source);
            var html = template(products[id]);
            $("#mylimsList_content").html(html)
        }else{
            var source = $("#mylimsList_content_tpl").html();
            var template = Handlebars.compile(source);
            var html = template(firstList);
            $("#mylimsList_content").html(html)
        }
    })

    $(".table .table_thead .t1").click(function () {
        $(this).siblings('ul').slideToggle(200, function () {
            if ($(this).is(":hidden")) {
                $(this).siblings('.t1').children(':first-child').text("[+]")
                $(this).siblings('.t1').removeClass('click-li')
            } else {
                $(this).siblings('.t1').children(':first-child').text("[-]")
                $(this).siblings('.t1').addClass('click-li')
            }
        });

    })
})